<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#parent {
				height: 200px;
				width: 200px;
				border: 1px solid red;
				position: relative;
				/* 设置相对定位 */
			}

			#child {
				/* 子元素已知自身宽高的情况下 */
				background-color: blue;
				width: 50px;
				height: 50px;
				margin-top: -25px;
				margin-left: -25px;
				position: absolute;
				left: 50%;
				top: 50%;
			}
		</style>
	</head>
	<body>
		<div id="parent">
			<div id="child"></div>
		</div>
	</body>
</html>
